These view modifiers are used to control the layout behavior of individual views placed inside a Grid
structure. They provide fine-grained control over cell spanning, alignment, and sizing, consistent with SwiftUI’s grid system.
gridCellColumns
Tells a view in a grid to span across multiple columns.
Use this modifier to expand a single view across two or more columns. This is typically used for headers or wide content rows.
gridCellAnchor
Specifies a custom alignment anchor within the grid cell.
Use this modifier to align the content of a cell to a specific anchor point, either using a named keyword (such as "center"
or "topLeading"
) or a custom { x, y }
point.
gridCellUnsizedAxes
Prevents the view from expanding in the specified directions when placed in a grid cell.
This modifier tells the grid not to assign extra size to the view along specified axes, allowing the view to tightly wrap its content.
"horizontal"
– Prevent horizontal expansion"vertical"
– Prevent vertical expansion"all"
– Prevent expansion in both directionsgridColumnAlignment
Overrides the default horizontal alignment of the column the view appears in.
Affects how all cells in the column are aligned horizontally. Only one view in a column needs to specify this to affect the whole column.
These modifiers are only applicable within the context of the Grid
and GridRow
components.
Grid
A container that lays out content in a two-dimensional grid.
alignment?: Alignment
– Alignment of child views in grid cellshorizontalSpacing?: number
– Spacing between columnsverticalSpacing?: number
– Spacing between rowsGridRow
Represents a horizontal row of views inside a Grid
.
alignment?: VerticalAlignment
– Vertical alignment for cells in the rowModifier | Description |
---|---|
gridCellColumns |
Allows a view to span multiple columns in the grid |
gridCellAnchor |
Sets a specific anchor point for the view within its cell |
gridCellUnsizedAxes |
Prevents the view from expanding along specified axes |
gridColumnAlignment |
Overrides the horizontal alignment of the containing column |